home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / loadseg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  1.8 KB  |  85 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: loadseg.c,v 1.3 1996/08/13 13:52:48 digulla Exp $
  4.     $Log: loadseg.c,v $
  5.     Revision 1.3  1996/08/13 13:52:48  digulla
  6.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  7.     Replaced __AROS_LA by __AROS_LHA
  8.  
  9.     Revision 1.2  1996/08/01 17:40:54  digulla
  10.     Added standard header for all files
  11.  
  12.     Desc:
  13.     Lang: english
  14. */
  15. #include <dos/dos.h>
  16. #include <clib/dos_protos.h>
  17. #include "dos/dosextens.h"
  18.  
  19. BPTR LoadSeg_AOS(BPTR file);
  20. BPTR LoadSeg_ELF(BPTR file);
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <clib/dos_protos.h>
  26.  
  27.     __AROS_LH1(BPTR, LoadSeg,
  28.  
  29. /*  SYNOPSIS */
  30.     __AROS_LHA(STRPTR, name, D1),
  31.  
  32. /*  LOCATION */
  33.     struct DosLibrary *, DOSBase, 25, Dos)
  34.  
  35. /*  FUNCTION
  36.     Loads an executable file into memory. Each hunk of the loadfile
  37.     is loaded into his own memory section and a handle on all of them
  38.     is returned. The segments can be freed with UnLoadSeg().
  39.  
  40.     INPUTS
  41.     name - NUL terminated name of the file.
  42.  
  43.     RESULT
  44.     Handle to the loaded executable or 0 if the load failed.
  45.     IoErr() gives additional information in that case.
  46.  
  47.     NOTES
  48.  
  49.     EXAMPLE
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.     UnLoadSeg()
  55.  
  56.     INTERNALS
  57.  
  58.     HISTORY
  59.     29-10-95    digulla automatically created from
  60.                 dos_lib.fd and clib/dos_protos.h
  61.  
  62. *****************************************************************************/
  63. {
  64.     __AROS_FUNC_INIT
  65.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  66.  
  67.     BPTR file, segs=0;
  68.  
  69.     /* Open the file */
  70.     file=Open(name,MODE_OLDFILE);
  71.     if(file)
  72.     {
  73.     /* Then try to load the different file formats */
  74. /*      segs=LoadSeg_AOS(file); Not yet */
  75.     if(!segs)
  76.         segs=LoadSeg_ELF(file);
  77.  
  78.     /* Clean up */
  79.     Close(file);
  80.     }
  81.     /* And return */
  82.     return segs;
  83.     __AROS_FUNC_EXIT
  84. } /* LoadSeg */
  85.